$(function (){

    // let params = new URLSearchParams(window.location.search);
    let jrId = params.get('jrId');



    console.log("test====>")
    console.log(jrId)
    console.log(localStorage.getItem("id"))
    console.log(localStorage.getItem("token"))

    $.ajax({
        headers:{
            "id":localStorage.getItem("id"),
            "token":localStorage.getItem("token")
        },
        type: 'get',
        url: `/dev/Details/jrId/${jrId}`,
        async: false,
        success:function (result){

            //java--关键词
            let str = ""
            for (let i=0;i<4;i++){
                str += `<li>${result.data.posKeyword}</li>`
            }
            $("#posKeywords").html(str)

            $("#posDescription").text(result.data.posDescription)
            //负责人，--刚刚活跃
            // $("#contactPerson").text(result.data.contactPerson)
            //公司名称
            //招聘者信息
            // $("#jravatar").text(result.data.jrAvatar).innerHTML;
            //招聘者的人的条条
            $("#jrName").text(result.data.jrName)
            $("#jrPlace").text(result.data.workPlace)
            //jr职位，要改的
            $("#jrType").text(result.data.jrType)

            $("#companyNames").text(result.data.companyName)
            document.getElementById("jravatar").children[0].src=result.data.jrAvatar

            document.getElementById("info-primary").children[0].src=result.data.jrAvatar

            document.getElementById("job-company-logo").children[0].src=result.data.jrAvatar
            //主要信息-------

            $("#posName").text(result.data.posName)
            $("#pay").text(Math.round(eval(result.data.payFloor/1000))+"K-"+Math.round(eval(result.data.payUpper/1000))+"K")
            $("#background").text(result.data.background)
            $("#expDemand").text(result.data.expDemand)
            // 先注掉，有数据再拿出来
            // $("#workPlace").text(result.data.workPlace)


            //公司名
            $("#company-name").text(result.data.companyName)
            //公司类型
            $("#companyTypes").text(result.data.companyType)

            $("#postType").text(result.data.posType)
            $("#employees").text(result.data.employeesQuantity)


            //右侧相似职位下的
            $("#posNames").text(result.data.posName)
            $("#pays").text(Math.round(eval(result.data.payFloor/1000))+"K-"+Math.round(eval(result.data.payUpper/1000))+"K")
            $("#companyName1").text(result.data.companyName)
            $("#workPlaces").text(result.data.workPlace)
            $("#companyIntro").text(result.data.companyIntro)


            //工商信息
            $("#companyName").text(result.data.companyName)
            //法定代表人
            $("#legalPerson").text(result.data.legalPerson)
            //经营状态
            $("#runState").text(result.data.runState)
            //成立时间
            $("#SetUpTime").text(result.data.setUpTime)
            //企业类型
            $("#companyType").text(result.data.companyType)
            //注册资金

            //地图--工作地址
            $("#workPlace1").text(result.data.workPlace)
            //注册地址
            $("#registerLocation").text(result.data.registerLocation)
            //营业起始

            $("#runBengin").text(result.data.runBengin)
            //所属地区

            //统一社会信用码
            $("#unifyCode").text(result.data.unifyCode)
            //核准时间
            $("#checkTime").text(result.data.checkTime)
            //曾用名
            $("#formerName").text(result.data.formerName)
            //等级机关
            $("#registrationAuthority").text(result.data.registrationAuthority)
            //经营范围
            $("#businessScope").text(result.data.businessScope)

        }
    })



    $.ajax({
        headers:{
            "id":localStorage.getItem("id"),
            "token":localStorage.getItem("token")
        },
        type: 'get',
        url: `/dev/Details/jrById/${jrId}`,
        async: false,
        success:function (result){
            let poster = document.querySelector(".J-box")
            let str=''
            for (let i=0;i<3;i++){
                let xueli = "";
                if (result.data[i].background==0){
                    xueli = "学历不限"
                }else if (result.data[i].background==1){
                    xueli = "本科以上"
                }else if (result.data[i].background==2){
                    xueli = "硕士以上"
                }else if (result.data[i].background==3){
                    xueli="博士"
                }

                str+=`<li>
                <a href="javascript:lik();" id="info-mouse" class="info-mouse" onmouseover="msover(this)" onmouseout="msout(this)">
                        <div class="info-primary"> 
                            <div class="name">
                                <span class="salary"  > ${Math.round(result.data[i].payFloor / 1000) + "K" + "-" + Math.round(result.data[i].payUpper / 1000) + "K"}</span>
                                <b >${result.data[i].posName}</b>
                                <div class="info-detail">
                                    <!--js事件--看到职位详情-->
                                </div>
                            </div>

                            <div class="info-primary-bottom">
                                <p class="tag-list">
                                    <span class="tag-list-item" >${result.data[i].expDemand}</span>
                                    <span class="tag-list-item" >${xueli}</span>
                                </p>
                                <span class="company-location" >${result.data[i].workPlace}</span>
                                <button class="btn-startchat" onclick="say()" id="startButton" style="display: none">立即沟通</button>

                            </div>
                        </div>
                    </a>
                </li>`
            }
            poster.innerHTML=str
        }})

    $.ajax({
        headers:{
            "id":localStorage.getItem("id"),
            "token":localStorage.getItem("token")
        },
        type: 'get',
        url: `/dev/Details/Count/${jrId}`,
        async: false,
        success:function (result){
            console.log(result.data)
            // console.log(document.getElementById("posNum"))
            $("#postNum").text(result.data)

            $("#pNum").text(result.data)

        }})

    function lik(){
        window.location.href=`/dev/views/job/page/boss.html?jrId=${jrId}`
    }

})

function msover(th) {
    th.children[0].children[1].children[2].style.display = "block"
    // startButton.style.display = "block"
};
function msout(th) {
    th.children[0].children[1].children[2].style.display = "none"
    // startButton.style.display = "none";

};

function companyde() {
    let params = new URLSearchParams(window.location.search);
    let jrId = params.get('jrId');
    console.log("jrID")
    console.log(jrId)
    jobd();
//     $.ajax({
//         type:'GET',
//         url:`/dev/Details/jrById/${jrId}`,
//         async:false,
//         success:function (result){
//             let poster = document.querySelector(".position-job-list")
//             let str=''
//             for (let i=0;i<=4;i++){
//                 let xueli = "";
//                 if (result.data[i].background==0){
//                     xueli = "学历不限"
//                 }else if (result.data[i].background==1){
//                     xueli = "本科以上"
//                 }else if (result.data[i].background==2){
//                     xueli = "硕士以上"
//                 }else if (result.data[i].background==3){
//                     xueli="博士"
//                 }
//                 str+=`
//                     <li class="job-card-box" onclick="vo(${result.data[i].id})">
//                             <div class="job-info">
//                                 <div class="job-title">
//                                     <a href="#" class="job-name">${result.data[i].posName}</a>
//                                     <span class="job-salary">${Math.round(result.data[i].payFloor / 1000) + "K" + "-" + Math.round(result.data[i].payUpper / 1000) + "K"}</span>
//                                 </div>
//                                 <ul class="tag-lists">
//                                     <li>${result.data[i].expDemand}</li>
//                                     <li>${xueli}</li>
//                                 </ul>
//                             </div>
//                             <!--王女士-->
//                             <div class="job-card-footer">
//                                 <div class="boss-info">
//                                     <div class="boss-logo">
//                                         <img src="/dev/assets/img/gg.jpg">
//                                         <span class="boss-online-icon"></span>
//                                     </div>
//                                     <span class="boss-name">王女士-招聘专员</span>
//                                 </div>
//                                 <span class="company-location">
//                                     <a href="#">${result.data[i].workPlace}</a>
// <!--                                    <span>杆子经区</span>-->
// <!--                                    <span>软件园</span>-->
//                                 </span>
//                             </div>
//                         </li>
//                         <!--多个li标签-->
//                     `
//             }
//             poster.innerHTML=str
//             //调用点击事件
//             vo(result.data[0].id)
//         }
//     })

    companyA.style.display='none';
    companyB.style.display='block';
    companyD.style.display='none';

    const elements = document.querySelectorAll('.job-card-box');
    let selectedElement = null;

    elements.forEach(element => {
        element.addEventListener('click', () => {
            if (selectedElement) {
                selectedElement.classList.remove('selected');
            }
            element.classList.add('selected');
            selectedElement = element;
        });
    });

};
//查看全部职位
function more() {
    let params = new URLSearchParams(window.location.search);
    let jrId = params.get('jrId');
    console.log("jrID")
    console.log(jrId)

    jobd()

//     $.ajax({
//         type:'GET',
//         url:`/dev/Details/jrById/${jrId}`,
//         async:false,
//         success:function (result){
//             let poster = document.querySelector(".position-job-list")
//             let str=''
//             for (let i=0;i<=4;i++){
//                 let xueli = "";
//                 if (result.data[i].background==0){
//                     xueli = "学历不限"
//                 }else if (result.data[i].background==1){
//                     xueli = "本科以上"
//                 }else if (result.data[i].background==2){
//                     xueli = "硕士以上"
//                 }else if (result.data[i].background==3){
//                     xueli="博士"
//                 }
//                 str+=`
//                     <li class="job-card-box" onclick="vo(${result.data[i].id})">
//                             <div class="job-info">
//                                 <div class="job-title">
//                                     <a href="#" class="job-name">${result.data[i].posName}</a>
//                                     <span class="job-salary">${Math.round(result.data[i].payFloor / 1000) + "K" + "-" + Math.round(result.data[i].payUpper / 1000) + "K"}</span>
//                                 </div>
//                                 <ul class="tag-lists">
//                                     <li>${result.data[i].expDemand}</li>
//                                     <li>${xueli}</li>
//                                 </ul>
//                             </div>
//                             <!--王女士-->
//                             <div class="job-card-footer">
//                                 <div class="boss-info">
//                                     <div class="boss-logo">
//                                         <img src="/dev/assets/img/gg.jpg">
//                                         <span class="boss-online-icon"></span>
//                                     </div>
//                                     <span class="boss-name">王女士-招聘专员</span>
//                                 </div>
//                                 <span class="company-location">
//                                     <a href="#">${result.data[i].workPlace}</a>
// <!--                                    <span>杆子经区</span>-->
// <!--                                    <span>软件园</span>-->
//                                 </span>
//                             </div>
//                         </li>
//                         <!--多个li标签-->
//                     `
//             }
//             poster.innerHTML=str
//             vo(result.data[0].id)
//         }
//     })

    companyA.style.display='none';
    companyD.style.display='none';
    companyB.style.display='block';
    //选中突出的样式
    const elements = document.querySelectorAll('.job-card-box');
    let selectedElement = null;

    elements.forEach(element => {
        element.addEventListener('click', () => {
            if (selectedElement) {
                selectedElement.classList.remove('selected');
            }
            element.classList.add('selected');
            selectedElement = element;
        });
    });

};

let POSTID
function vo(id) {
    console.log(id)
    let posNamer = $("#InputSelect").val()
    $.ajax({
        headers:{
            "id":localStorage.getItem("id"),
            "token":localStorage.getItem("token")
        },

        type: 'get',
        url: `/dev/PostsSearch/findById`,
        data:{"id":id,"posDescription":posNamer},
        async: false,
        success: function (result) {
            console.log(result)
            //object
            //隐藏posid
            $("#posid").val(id)
            //职位名
            $("#jobName-1").text(result.data[0].content.posName)
            //薪资范围
            $("#jobSalary-1").text(Math.round(eval(result.data[0].content.payFloor/1000))+"K-"+Math.round(eval(result.data[0].content.payUpper/1000))+"K")
            //工作地点
            $("#workPlace-1").text(result.data[0].content.workPlace)
            //经验
            $("#expDemand-1").text(result.data[0].content.expDemand)
            //学历要求
            $("#background-1").text(result.data[0].content.background)

            //职位关键词
            let str = ""
            // for (let i=0;i<4;i++){
                str += `<li>${result.data[0].content.posKeyword}</li>`
            // }
            $("#posKeyWord").html(str)
            //职位关键词
            // $("#posKeyWord").text(result.data[0].content.posKeyword)

            //职位描述
            $("#posDescriptions").html(result.data[0].highlightFields.posDescription==null?result.data[0].content.posDescription:result.data[0].highlightFields.posDescription)
            // 获取要插入图像的容器元素

            // let image = document.getElementById("jr_avatar");
            // let imageElement = document.createElement("img");
            // imageElement.src = result.data[0].content.jrAvatar
            // image.appendChild(imageElement)
            // console.log("asc")
            // console.log(result.data[0].content)
            document.getElementById("jr_avatar").children[0].src=result.data[0].content.jrAvatar


            // $("#jr_avatar").text(result.data[0].content.jrAvatar)
            $("#jr_name").text(result.data[0].content.jrName)

            $("#company_name").text(result.data[0].content.companyName)
            $("#company_type").text(result.data[0].content.jrType)

            $("#company_adress").text(result.data[0].content.workPlace)

            POSTID = id

            // $("#moreThan").click(
            //     window.location.href = `/dev/views/job/page/boss.html?posId=${posId}`
            // )


        }
    })
}
function mor() {
    window.location.href = `/dev/views/job/page/boss.html?posId=${POSTID}`
}
// var inputElement=document.getElementById("InputSelect")
//按钮查询事件
function jobd(){
    // var posNamer=inputElement.value;
    var posNamer = $("#InputSelect").val();
    console.log(posNamer+"==sosia")
    let doc = document.querySelector(".company-position-box")
    let hidd = document.querySelector(".hidd")
    let params = new URLSearchParams(window.location.search);
    let jrId = params.get('jrId');
    if (posNamer==='') {
        hidd.style.display="none"
        doc.style.display="block"
        $.ajax({
            headers: {
                "id": localStorage.getItem("id"),
                "token": localStorage.getItem("token")
            },
            type: 'POST',
            url: `/dev/Details/Find`,
            data: {"posName": posNamer, "jrId": jrId},
            async: false,
            success: function (result) {
                let page = [1, 5]

                layui.use(function () {
                    var laypage = layui.laypage;
                    laypage.render({
                        elem: 'demo-laypage-normal-2',
                        count: result.data.length, // 数据总数
                        limit: page[1],
                        jump: function (obj) {
                            page[0] = obj.curr; // 得到当前页，以便向服务端请求对应页的数据
                            let poster = document.querySelector(".position-job-list")
                            if (result.code == 200) {
                                console.log("reu++++++")
                                console.log(result)
                                let str = '';
                                for (let i = (page[0] - 1) * page[1]; i < ((page[0] - 1) * page[1]) + page[1]; i++) {
                                    if (result.data[i] == null) {
                                        break
                                    }
                                    let xueli = "";
                                    if (result.data[i].background == 0) {
                                        xueli = "学历不限"
                                    } else if (result.data[i].background == 1) {
                                        xueli = "本科以上"
                                    } else if (result.data[i].background == 2) {
                                        xueli = "硕士以上"
                                    } else if (result.data[i].background == 3) {
                                        xueli = "博士"
                                    }
                                    str += `
                     <li class="job-card-box" onclick="vo(${result.data[i].id})">
                            <div class="job-info">
                                <div class="job-title">
                                    <a href="#" class="job-name">${result.data[i].posName}</a>
                                    <span class="job-salary">${Math.round(result.data[i].payFloor / 1000) + "K" + "-" + Math.round(result.data[i].payUpper / 1000) + "K"}</span>
                                </div>
                                <ul class="tag-lists">
                                    <li>${result.data[i].expDemand}</li>
                                    <li>${xueli}</li>
                                </ul>
                            </div>
                            <!--王女士-->
                            <div class="job-card-footer">
                                <div class="boss-info">
                                    <div class="boss-logo" id="JR_javtar">
<!--                                    招聘者头像-->
<!--                                        <img src="">-->
<!--                                        <span class="boss-online-icon"></span>-->
                                    </div>
                                    <span class="boss-name">联系电话      ${result.data[i].posTelephone}</span>
                                </div>
                                <span class="company-location">
                                    <a href="#">${result.data[i].workPlace}</a>
<!--                                    <span>杆子经区</span>-->
<!--                                    <span>软件园</span>-->
                                </span>
                            </div>
                        </li>
                    `
                                }
                                poster.innerHTML = str;

                                console.log(result.data[0])
                                //页面初加载的点击事件，放
                                vo(result.data[0].id)

                                const elements = document.querySelectorAll('.job-card-box');
                                let selectedElement = null;

                                elements.forEach(element => {
                                    element.addEventListener('click', () => {
                                        if (selectedElement) {
                                            selectedElement.classList.remove('selected');
                                        }
                                        element.classList.add('selected');
                                        selectedElement = element;
                                    });
                                });

                                return "ok";
                            } else {
                                return false;
                            }


                        }
                    });
                });


            }
        })
    }else {

        $.ajax({
            headers: {
                "id": localStorage.getItem("id"),
                "token": localStorage.getItem("token")
            },
            type: 'GET',
            url: `/dev/PostsSearch/select`,
            data: {"jrId": jrId,"posName": posNamer},
            async: false,
            success: function (result) {
                if (result.data == null || result.data === []) {
                    // next("", true);
                    // $("#position-job-container").html = "";
                    // document.querySelector(".position-job-list").innerHTML=""
                    // document.querySelector('.job-detail-box').innerHTML=""
                    doc.style.display="none"
                    hidd.style.display="block"
                    return ;
                }
                hidd.style.display="none"
                doc.style.display="block"
                console.log(posNamer+"bus")
                console.log(jrId+"=-=-=-")
                let page = [1, 5]
                console.log("++++++++++")
                console.log(result)
                // console.log(layui.layPage)
                // if (layui.layPage!==undefined){
                //     layui.layPage.render.destroy("demo-laypage-normal-2")
                // }

                layui.use(function () {
                    var laypage = layui.laypage;
                    laypage.render({
                        elem: 'demo-laypage-normal-2',
                        count: result.data.length, // 数据总数
                        limit: page[1],
                        jump: function (obj) {
                            page[0] = obj.curr; // 得到当前页，以便向服务端请求对应页的数据
                            let poster = document.querySelector(".position-job-list")
                            if (result.code == 200) {

                                let str = '';
                                for (let i = (page[0] - 1) * page[1]; i < ((page[0] - 1) * page[1]) + page[1]; i++) {
                                    if (result.data[i] == null) {
                                        break
                                    }
                                    let xueli = "";
                                    if (result.data[i].content.background == 0) {
                                        xueli = "学历不限"
                                    } else if (result.data[i].content.background == 1) {
                                        xueli = "本科以上"
                                    } else if (result.data[i].content.background == 2) {
                                        xueli = "硕士以上"
                                    } else if (result.data[i].content.background == 3) {
                                        xueli = "博士"
                                    }
                                    str += `
                     <li class="job-card-box" onclick="vo(${result.data[i].content.id})">
                            <div class="job-info">
                                <div class="job-title">
                                    <a href="#" class="job-name">${result.data[i].highlightFields.posName==null?result.data[i].content.posName:result.data[i].highlightFields.posName}</a>
                                    <span class="job-salary">${Math.round(result.data[i].content.payFloor / 1000) + "K" + "-" + Math.round(result.data[i].content.payUpper / 1000) + "K"}</span>
                                </div>
                                <ul class="tag-lists">
                                    <li>${result.data[i].content.expDemand}</li>
                                    <li>${xueli}</li>
                                </ul>
                            </div>
                            <!--王女士-->
                            <div class="job-card-footer">
                                <div class="boss-info">
                                    <div class="boss-logo">
                                        <img src="${result.data[i].content.jrAvatar}">
                                        <span class="boss-online-icon"></span>
                                    </div>
                                    <span class="boss-name">${result.data[i].content.jrName}</span>
                                </div>
                                <span class="company-location">
                                    <a href="#">${result.data[i].content.workPlace}</a>
<!--                                    <span>杆子经区</span>-->
<!--                                    <span>软件园</span>-->
                                </span>
                            </div>
                        </li>
                    `
                                }
                                poster.innerHTML = str;

                                console.log(result.data[0])
                                vo(result.data[0].content.id)

                                const elements = document.querySelectorAll('.job-card-box');
                                let selectedElement = null;
                                elements.forEach(element => {
                                    element.addEventListener('click', () => {
                                        if (selectedElement) {
                                            selectedElement.classList.remove('selected');
                                        }
                                        element.classList.add('selected');
                                        selectedElement = element;
                                    });
                                });
                                return "ok";
                            } else {
                                return false;
                            }

                        }
                    });
                });


            }
        })

    }
}

//社区界面

const commentBox = document.querySelector(".comment-wrap");
const personComment = document.getElementById("person-comment")

let commentBoxVisible = false;
function personC(is) {
    console.log("axs")
    console.log(commentBoxVisible)
    console.log(is)
    if (!commentBoxVisible) {
        // 显示评论框
        is.parentNode.parentNode.children[1].style.display = "block";
        console.log(commentBox)
        commentBoxVisible = true;
        let numsId = 0
        let flowsib = is.parentElement.nextElementSibling.children[1].children[0].nextElementSibling.children[0]
        let flowId = flowsib.id
        layui.use(function () {
            var flow = layui.flow;
            console.log("================")
            // 流加载实例
            flow.load({
                elem: `#${flowId}`, // 流加载容器
                //scrollElem: '.ID-flow-demo-manual', // 滚动条所在元素，一般不用填，此处只是演示需要。
                isAuto: false,
                isLazyimg: true,
                done: function (page, next) { // 加载下一页
                    // 模拟插入
                    setTimeout(function () {
                        let problemId = is.parentElement.nextElementSibling.children[0].children[1].children[0].value
                        console.log(problemId)
                        $.ajax({
                            headers:{
                                "id":localStorage.getItem("id"),
                                "token":localStorage.getItem("token")
                            },
                            url:"/dev/comment/searchComment",
                            type:"post",
                            data:{
                                "problemId": problemId,
                            },
                            success:function (result){
                                var lis = [];
                                let start = (page - 1) * 3;
                                let end = Math.min(start + 3, result.data.length)
                                for (var i = start; i < end; i++) {
                                    lis.push(`<li class="cmt-node">
                                <ul>
                                    <li class="cmt-item">
                                        <div class="cmt-avatar" style="background: url('${result.data[i].avatar}');"></div>
                                        <div class="cmt-item-content">
                                            <div class="cmt-user-info">
                                                <div >
                                                    <div class="user-title">
                                                        <span class="user-name">${result.data[i].jsName}</span>
                                                    </div>
                                                    <p class="user-sub-title"></p>
                                                </div>

                                                                                        <!--日期-->
                                                <div class="cmt-item-end-content">
                                                    <p class="add-time">${result.data[i].createTime}</p>
                                                </div>
                                            </div>
                                            <!--评论内容-->
                                            <p class="cmt-content">${result.data[i].comment}</p>
                                            <div class="cmt-item-options">
                                                <div class="cmt-item-option like">
                                                    <i class="layui-icon layui-icon-heart"></i>
                                                    <span>赞</span>
                                                </div>
                                                <div class="cmt-item-option-hiddenReply" onclick="zbc1(this)" >
                                                    <i class="layui-icon layui-icon-reply-fill"></i>
                                                    <span>回复</span>
                                                    <!-- <span class="close-cmt">收起回复</span> -->
                                                </div>
                                                <div class="selAll">
                                                    <i class="layui-icon layui-icon-down"></i>
                                                    <button class="sells" onclick="sells(this);">展开全部回复</button>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- </li> -->
                                        <!--隐藏评论下面的回复 给个js事件展开来看-->
                                        <div class="cmt-input" style="display: none;">
                                            <div class="cmt-item">
                                                <div class="input-wrap-textarea">
                                                    <label >
                                                        <textarea wrap="soft" class="input" autocomplete="on" placeholder="回复:" style="height: 37.6px;min-height: 37.6px;"></textarea>
                                                    </label>
                                                </div>
                                            </div>
                                            <!--回复按钮-->
                                            <div class="options">
                                                <button class="reply-btn empty" style="background: #00b8bf;cursor: pointer" onclick="publishResponse(this)">回复</button>
                                                <input type="hidden" value="${result.data[i].id}">
                                            </div>
                                        </div>
                                    </li>
                                    <!--回复-->
                                        <div class="flow-demo" id="ID-flow-demos${numsId++}${result.data[i].id}" style="display: none;">
                                            <div class="cmt-sub-list-wrap" style="display: none;" >
                                                <ul class="cmt-sub-list">
                                                    <li class="cmt-item">
                                                        <div class="cmt-avatar" style="background: url('${result.data[i].avatar}');"></div>
                                                        <div class="cmt-item-content">
                                                            <div class="cmt-user-info">
                                                                <div >
                                                                    <div class="user-title">
                                                                        <span class="user-name">赵建云</span>
                                                                    </div>
                                                                    <p class="user-sub-title"></p>
                                                                </div>

                                                                <!--日期-->
                                                                <div class="cmt-item-end-content">
                                                                    <p class="add-time">10/20 9.21</p>
                                                                </div>
                                                            </div>
                                                            <p class="cmt-content">哈哈哈真不错</p>
                                                            <div class="cmt-item-options">
                                                                <div class="cmt-item-option like">
                                                                    <i class="layui-icon layui-icon-heart"></i>
                                                                    <span>${result.data[i].likeNum}赞</span>
                                                                </div>
                                                                <div class="cmt-item-option-hiddenReply" >
                                                                    <i class="layui-icon layui-icon-reply-fill"></i>
                                                                    <span>${result.data.length}回复</span>
                                                                    <!-- <span class="close-cmt">收起回复</span> -->
                                                                </div>
                                                            </div>



                                                        </div>
                                                    </li>


                                                    <!-- <p class="see-more">
                                                        <span class="sm-text">全部<i>2</i>条回复</span>
                                                    </p> -->
                                                </ul>
                                            </div>
                                            <!--layui的div-->
                                        </div>
                                        <!--回复结束-->
                                </ul >

                            </li >`)
                                }
                                next(lis.join(''), page < Math.ceil(result.data.length / 3)); // 假设总页数为 6
                            }
                        })

                    }, 520);
                }
            });
        });
    } else {
        // 隐藏评论框
        is.parentNode.parentNode.children[1].style.display = "none";
        commentBoxVisible = false;
    }
}


const commentreply = document.querySelector(".cmt-input");
const hiddenReply = document.querySelector(".cmt-item-option-hiddenReply");
let commentBoxVisibles = false;

// hiddenReply.addEventListener("click", function () {
function zbc1(is) {
    let parentzbc1 = is.parentNode.parentNode.parentNode.children[2]
    if (parentzbc1.style.display=="none") {
        // 显示评论框
        parentzbc1.style.display = "block";
        commentBoxVisibles = true;
        let commentId = is.nextElementSibling.value
        console.log(commentId)
        let responseFlow = is.parentElement.parentElement.parentElement.nextElementSibling.id
        console.log(responseFlow)
        layui.use(function () {
            var flow = layui.flow;
            // 流加载实例
            flow.load({
                elem: `#${responseFlow}`, // 流加载容器
                //scrollElem: '#ID-flow-demo-manual', // 滚动条所在元素，一般不用填，此处只是演示需要。
                isAuto: false,
                isLazyimg: true,
                done: function (page, next) { // 加载下一页
                    // 模拟插入
                    setTimeout(function () {
                        $.ajax({
                            headers: {
                                "id": localStorage.getItem("id"),
                                "token": localStorage.getItem("token")
                            },
                            url: "/dev/response/searchResponse",
                            type: "post",
                            data: {
                                "commentId": commentId
                            },
                            success: function (result) {
                                if (result.code==200){
                                    var lis = [];
                                    let start = (page - 1) * 3;
                                    let end = Math.min(start + 3, result.data.length)
                                    for (var i = start; i < end; i++) {
                                        lis.push(`<div class="cmt-sub-list-wrap">
                                                                                <ul class="cmt-sub-list">
                                                                                    <li class="cmt-item">
                                                                                        <div class="cmt-avatar" style="background: url('${result.data[i].avatar}');"></div>
                                                                                        <div class="cmt-item-content">
                                                                                            <div class="cmt-user-info">
                                                                                                <div >
                                                                                                    <div class="user-title">
                                                                                                        <span class="user-name">${result.data[i].jsName}</span>
                                                                                                    </div>
                                                                                                    <p class="user-sub-title"></p>
                                                                                                </div>

                                                                                                <!--日期-->
                                                                                                <div class="cmt-item-end-content">
                                                                                                    <p class="add-time">${result.data[i].createTime}</p>
                                                                                                </div>
                                                                                            </div>
                                                                                            <p class="cmt-content">${result.data[i].response}</p>
                                                                                            <div class="cmt-item-options">
                                                                                                <div class="cmt-item-option like">
                                                                                                    <i class="layui-icon layui-icon-heart"></i>
                                                                                                    <span>赞</span>
                                                                                                </div>
                                                                                                <div class="cmt-item-option-hiddenReplys" onclick="sec(this);">
                                                                                                    <i class="layui-icon layui-icon-reply-fill"></i>
                                                                                                    <span>${result.data.length}回复</span>
                                                                                                    <!-- <span class="close-cmt">收起回复</span> -->
                                                                                                </div>
                                                                                            </div>

                                                                                        </div>

                                                                                        <div class="cmt-inputa" style="display: none;">
                                                                                            <div class="cmt-item">
                                                                                                <div class="input-wrap-textarea">
                                                                                                    <label >
                                                                                                        <textarea wrap="soft" class="input" autocomplete="on" placeholder="回复:" style="height: 37.6px;min-height: 37.6px;"></textarea>
                                                                                                    </label>
                                                                                                </div>
                                                                                            </div>
                                                                                            <!--回复按钮-->
                                                                                            <div class="options">
                                                                                                <button class="reply-btn empty" style="background: #00b8bf;cursor: pointer">评论</button>
                                                                                            </div>
                                                                                        </div>
                                                                                    </li>
                                                                                </ul>
                                                                            </div>`)
                                    }
                                    next(lis.join(''), page < Math.ceil(result.data.length / 3)); // 假设总页数为 6
                                }else {
                                    sg.innerHTML=`<h4>暂无回复</h4>`
                                }

                            }
                        })

                    }, 520);
                }
            });
        });
    } else {
        // 隐藏评论框
        parentzbc1.style.display = "none";
        commentBoxVisibles = false;
    }
};


function cops() {
    let content = document.getElementById("cop-text")
    let Cops = document.querySelector(".cops");
    if (content.classList.contains("expanded")) {
        content.classList.remove("expanded");
        Cops.textContent = "展开";

    } else {
        content.classList.add("expanded");
        Cops.textContent = "收起";

    }
}

//展开全部回复
const lk = document.querySelector(".sells")
let sg = document.getElementById("ID-flow-demos")
let commentBoxs = false;
function sells(is) {
    console.log("abcd")
    let icon = document.querySelector(".selAll i"); // 选择 i 元素
    console.log(is.parentNode.parentNode.parentNode.parentNode.parentNode.children[1])
    icon = is.parentNode.children[0]
    sg = is.parentNode.parentNode.parentNode.parentNode.parentNode.children[1]
    let idSG = sg.id
    let commentId = is.parentElement.parentElement.parentElement.nextElementSibling.children[1].children[1].value
    console.log(commentId)
    console.log(idSG)
    if (!commentBoxs) {
        // 显示评论框
        sg.style.display = 'block'
        commentBoxs = true;
        is.textContent = "收起"
        // 设置 class 属性
        icon.className = "layui-icon layui-icon-up";
        //回复加载
        layui.use(function () {
            var flow = layui.flow;
            // 流加载实例
            flow.load({
                elem: `#${idSG}`, // 流加载容器
                //scrollElem: '#ID-flow-demo-manual', // 滚动条所在元素，一般不用填，此处只是演示需要。
                isAuto: false,
                isLazyimg: true,
                done: function (page, next) { // 加载下一页
                    // 模拟插入
                    setTimeout(function () {
                        $.ajax({
                            headers: {
                                "id": localStorage.getItem("id"),
                                "token": localStorage.getItem("token")
                            },
                            url: "/dev/response/searchResponse",
                            type: "post",
                            data: {
                                "commentId": commentId
                            },
                            success: function (result) {
                                console.log(result)
                                if (result.code==200&&result.data.length>=0){
                                    var lis = [];
                                    let start = (page - 1) * 3;
                                    let end = Math.min(start + 3, result.data.length)
                                    for (var i = start; i < end; i++) {
                                        lis.push(`<div class="cmt-sub-list-wrap">
                                                                                <ul class="cmt-sub-list">
                                                                                    <li class="cmt-item">
                                                                                        <div class="cmt-avatar" style="background: url('${result.data[i].avatar}');"></div>
                                                                                        <div class="cmt-item-content">
                                                                                            <div class="cmt-user-info">
                                                                                                <div >
                                                                                                    <div class="user-title">
                                                                                                        <span class="user-name">${result.data[i].jsName}${result.data[i].optionJsName==""?'':'to'}${result.data[i].optionJsName==null?'':result.data[i].optionJsName}</span>
                                                                                                    </div>
                                                                                                    <p class="user-sub-title"></p>
                                                                                                </div>
    
                                                                                                <!--日期-->
                                                                                                <div class="cmt-item-end-content">
                                                                                                    <p class="add-time">${result.data[i].createTime}</p>
                                                                                                </div>
                                                                                            </div>
                                                                                            <p class="cmt-content">${result.data[i].response}</p>
                                                                                            <div class="cmt-item-options">
                                                                                                <div class="cmt-item-option like">
                                                                                                    <i class="layui-icon layui-icon-heart"></i>
                                                                                                    <span>${result.data[i].likeNum}</span>
                                                                                                </div>
                                                                                                <div class="cmt-item-option-hiddenReplys" onclick="sec(this);">
                                                                                                    <i class="layui-icon layui-icon-reply-fill"></i>
                                                                                                    <span>回复</span>
                                                                                                    <!-- <span class="close-cmt">收起回复</span> -->
                                                                                                </div>
                                                                                            </div>
    
                                                                                        </div>
                                                                                    
                                                                                        <div class="cmt-inputa" style="display: none;">
                                                                                            <div class="cmt-item">
                                                                                                <div class="input-wrap-textarea">
                                                                                                    <label >
                                                                                                        <textarea wrap="soft" class="input" autocomplete="on" placeholder="回复:" style="height: 37.6px;min-height: 37.6px;"></textarea>
                                                                                                    </label>
                                                                                                </div>
                                                                                            </div>
                                                                                            <!--回复按钮-->
                                                                                            <div class="options">
                                                                                                <button class="reply-btn empty" style="background: #00b8bf;cursor: pointer" onclick="innerResponse(this)">回复</button>
                                                                                                <input type="hidden" value="${result.data[i].jsName}">
                                                                                                <input type="hidden" value="${commentId}">
                                                                                            </div>
                                                                                        </div>
                                                                                    </li>
                                                                                </ul>
                                                                            </div>`)
                                    }
                                    next(lis.join(''), page < Math.ceil(result.data.length / 3)); // 假设总页数为 6
                                }else {
                                    sg.innerHTML=`<h4>暂无回复</h4>`
                                }

                            }
                        })

                    }, 520);
                }
            });
        });
    } else {
        // 隐藏评论框

        is.textContent = "展开全部回复"
        sg.style.display = 'none'
        commentBoxs = false;
        icon.className = "layui-icon layui-icon-down";
    }




}






let commentBS = false;
function sec(is) {
    let parentsec=is.parentNode.parentNode.parentNode.children[2]
    console.log("NSBVAHA")
    if (parentsec.style.display == "none") {
        // 显示评论框
        parentsec.style.display = "block";
        commentBS = true;
    } else {
        // 隐藏评论框
        parentsec.style.display = "none";
        commentBS = false;
    }
}

let params = new URLSearchParams(window.location.search);
let jrId = params.get('jrId');
console.log(jrId)
layui.use(function () {
    var $ = layui.$;
    var layer = layui.layer;
    var util = layui.util;
    console.log(jrId)
    // 事件
    util.on('lay-on', {
        'test-iframe-handle': function () {
            layer.open({
                type: 2,
                area: ['680px', '520px'],
                content: '/layer/test/iframe.html',
                fixed: false, // 不固定
                maxmin: true,
                shadeClose: true,
                btn: ['获取表单值', '取消'],
                btnAlign: 'c',
                yes: function (index, layero) {
                    // 获取 iframe 的窗口对象
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    var elemMark = iframeWin.$('#mark'); // 获得 iframe 中某个输入框元素
                    var value = elemMark.val();

                    if ($.trim(value) === '') return elemMark.focus();
                    // 显示获得的值
                    layer.msg('获得 iframe 中的输入框标记值：' + value);
                }
            });
        },
        'test-iframe-curl': function () {
            layer.open({
                type: 2,
                title: '发布问题',
                shadeClose: true,
                maxmin: true, //开启最大化最小化按钮
                area: ['900px', '600px'],
                content: `/dev/views/job/page/sendproblem.html?jrId=${jrId}`,
                end: function (){
                    location.reload()
                }
            });


        }
    })
});

// let params = new URLSearchParams(window.location.search);
let posId = params.get('posId');
let interest = document.querySelector("#interest")
interest.addEventListener('click',function (){
    let btn1 = '<i class="layui-icon layui-icon-heart"></i>感兴趣'
    let btn2 = '<i class="layui-icon layui-icon-heart-fill"></i>取消感兴趣'
    let posId = document.querySelector("#posid").value
    if (this.innerHTML===btn1){
        this.innerHTML=btn2
        $.ajax({
            headers:{
                "id":localStorage.getItem("id"),
                "token":localStorage.getItem("token")
            },
            url:"/dev/collect/add",
            type: "post",
            async: false,
            data:{
                "jsId": localStorage.getItem("id"),
                "posId": posId
            },
            success:function (result){
                console.log(result)
                if (result.code==200){
                }
            }
        })
    }else {
        this.innerHTML=btn1
        $.ajax({
            headers:{
                "id":localStorage.getItem("id"),
                "token":localStorage.getItem("token")
            },
            url:"/dev/collect/delete",
            type:"post",
            data: {
                "jsId": localStorage.getItem("id"),
                "posId": posId
            },
            success:function (result){
                console.log(result)
                if (result.code==200){

                }
            }
        })
    }

})

